package pro.softzhang.algo.lc2100;

import pro.softzhang.algo.common.ListNode;

import java.util.ArrayList;
import java.util.List;

/**
 *
 */
public class LC2130_MaximumTwinSumOfALinkedList {
    public static void main(String[] args) {

    }

    /**
     * 转成其他能双向获取的结构
     */
    static
    class Solution {
        public int pairSum(ListNode head) {
            List<Integer> arr = new ArrayList<>();
            while (head != null) {
                arr.add(head.val);
                head = head.next;
            }

            int maxPairSum = 0;
            for(int i = 0, j = arr.size() - 1; i < j; i++, j--) {
                maxPairSum = Math.max(arr.get(i) + arr.get(j), maxPairSum);
            }
            return maxPairSum;
        }
    }
}
